package com.stone.front.other.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.stone.base.controller.BaseController;
import com.stone.common.util.MailClient;

/**
 * 商品管理
 * @author Stone P
 *
 */
@Controller
public class BreakFastController extends BaseController {
	/**
	 * 访问首页
	 * @return
	 */
	@RequestMapping("/index")
    public ModelAndView index(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/index");
		return mv;
	}
	
	/**
	 * 访问健康页1
	 * @return
	 */
	@RequestMapping("/health1")
    public ModelAndView health1(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/front/health1");
		return mv;
	}
	
	/**
	 * 访问健康页2
	 * @return
	 */
	@RequestMapping("/health2")
    public ModelAndView health2(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/front/health2");
		return mv;
	}
	
	/**
	 * 访问填写订单信息页
	 * @return
	 */
	@RequestMapping("/orderinput")
    public ModelAndView orderInput(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/front/orderinput");
		return mv;
	}
	
	/**
	 * 访问用户详情页
	 * @return
	 */
	@RequestMapping("/userinfo")
    public ModelAndView userInfo(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/front/userinfo");
		return mv;
	}
	
	/**
	 * 访问送餐页
	 * @return
	 */
	@RequestMapping("/gift")
    public ModelAndView gift(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/front/gift");
		return mv;
	}
	
	/**
	 * 访问联系我们页
	 * @return
	 */
	@RequestMapping("/contact")
    public ModelAndView contact(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/front/contact");
		return mv;
	}
	
	/**
	 * 意见反馈发邮件
	 * @param userName		用户名
	 * @param suject		主题
	 * @param content		意见
	 * @return
	 */
	@RequestMapping("/contactSendMail")
	public @ResponseBody boolean contactSendMail(String userName, String suject, String content, HttpServletRequest request) {
		MailClient mailClient = new MailClient();
		mailClient.setSuject(suject);
		mailClient.setFromName("意见反馈");
		mailClient.setStrBufferCon(userName + "  想对您说：\n        " + content);
		boolean sendStatus = true;
		try {
			sendStatus = mailClient.sendMail(mailClient.getFromAddr(), "");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return sendStatus;
	}
}